<?php
namespace models;

class students
{

    // 取指定班级、座位的学生信息
    public function getOne($class_id, $site)
    {

        return db('students')
            ->where('site = ? and class_id = ?', [$site, $class_id])
            ->fetch();

    }

    public function getAll($class_id)
    {
        $db = db('students')->where('class_id=?', $class_id)->order('site')->fetchAll();
        if (empty($db)) {
            $r['code']  = 1;
            $r['data']  = null;
            $r['count'] = 0;
            $r['msg']   = '本班级暂无学生';
        } else {
            $r['code']  = 0;
            $r['data']  = $db;
            $r['count'] = count($db);
        }
        return $r;
    }

    

}
